package com.xin.jdbc_02;

import java.sql.*;
import java.util.Scanner;

public class sqlin {
    public static void main(String[] args) {
        //接收账号密码的界面
        Scanner sc=new Scanner(System.in);
        int id=sc.nextInt();
        int password=sc.nextInt();
        //jdbc类
        Connection conn=null;
        Statement sta=null;
        ResultSet re=null;
        try {
            Class.forName("com.mysql.jdbc.Driver");
            conn=DriverManager.getConnection("jdbc:mysql://localhost:3306/stu_manage","root","856736");
            re = sta.executeQuery("select * from idpssword where id=1 and  password=1");
            if (re.next()){
                System.out.println("登录成功");
            }else{
                System.out.println("登录失败");
            }
        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            if(re!=null){
                try {
                    re.close();
                } catch (SQLException e) {
                    e.printStackTrace();
                }
            }if(sta!=null){
                try {
                    sta.close();
                } catch (SQLException e) {
                    e.printStackTrace();
                }
            }if(conn!=null){
                try {
                    conn.close();
                } catch (SQLException e) {
                    e.printStackTrace();
                }
            }
        }
    }
}
